package com.swk.version4.bookCity;

import java.util.List;

import org.junit.Test;

import com.swk.version4.base.BaseNovel;
import com.swk.version4.bean.Chapter;
import com.swk.version4.behaviorImpl.ConnectWithoutLogin;
import com.swk.version4.behaviorImpl.HandleListForDingDianxs;
import com.swk.version4.behaviorImpl.HandleTextForDingdianxs;

/**
 * 
 * @author 慎伟康
 * 
 * @date 2018年1月13日 下午11:24:26
 * 
 * @Description
 *    顶点小说网
 *    https://www.x23us.com/
 */
public class DingDianxs extends BaseNovel {

	/**
	 * 空参构造器，将合适的解析算法组合起来。
	 */
	public DingDianxs() {
		super();
		setConnectWebPageBehavior(new ConnectWithoutLogin());
		setHandleChapterContentBehavior(new HandleTextForDingdianxs());
		setHandleChapterListBehavior(new HandleListForDingDianxs());
	}
	
	@Test
	public void testList(){//测试获取章节列表方法
		String url = "https://www.x23us.com/html/0/146/";//修仙狂徒
		String analyzeParam = "146/";

		List<Chapter> list = getChapterList(url, analyzeParam);
		for (Chapter chapter : list) {
			System.out.println(chapter.getChapterHref() + "-->" + chapter.getChapterName());
		}
		System.out.println(list.size());
	}
	
	@Test
	public void testText(){//测试获取单章文本方法
		String url = "https://www.x23us.com/html/0/146/15985723.html";//修仙狂徒
		
		String s = getChapterText(url);
		System.out.println(s);
	}
	
	@Test
	public void xiuXianKuangTu(){//修仙狂徒
		String url = "https://www.x23us.com/html/0/146/";
		String pathname = "src/com/swk/novel/修仙狂徒.txt";
		String analyzeParam = "146/";
//		downloadAll(url, pathname, analyzeParam);
		download(url, pathname, 3350, analyzeParam);
	}
}
